//
// Created by 紫霄 on 2020/4/24.
//

#ifndef LEETCODE_54_H
#define LEETCODE_54_H
// 二分法 逻辑问题
#include <vector>
using namespace std;
class Solution {
public:
  int missingNumber(vector<int> &nums) {
    int sz = nums.size();
    int lo = 0;
    int hi = sz - 1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (nums[mid] == mid) {
        lo = mid + 1;
      } else {
        hi = mid - 1;
      }
    }
    return lo;
  }
};
#endif // LEETCODE_54_H
